<template>
  <div class="app-content">
    <div class="app-main">
      <router-view v-slot="{ Component }">
        <transition name="page">
          <keep-alive>
            <component :is="Component" />
          </keep-alive>
        </transition>
      </router-view>
    </div>
    <div class="app-tabbar">
      <fs-tab-bar />
    </div>
    <transition name="music">
      <music-player />
    </transition>
    <fs-drag-ball @drag-click="handleDragClick" />
  </div>
</template>

<script setup lang="ts">
import FsTabBar from "./components/FsTabBar/FsTabBar.vue";
import FsDragBall from "./components/FsDragBall/FsDragBall.vue";
import musicPlayer from "@/views/musicPlayer/index.vue";
import useTheme from "./hooks/useTheme";
import mitter from "./utils/mitt";
const { initTheme } = useTheme();
initTheme();

const handleDragClick = () => {
  mitter.emit("openMusicPlayer");
};
</script>
<style scoped lang="scss">
.app-content {
  width: 100vw;
  height: 100vh;
  background-color: #ccf2f4;
  color: var(--font-color);
  .app-main {
    position: relative;
    width: 100%;
    height: calc(100vh - 65px);
  }
}
.page-leave-active {
  transition: all 0.4s ease-in-out;
  border-radius: 22px;
  animation: page-out 1.25s linear;
}

.page-enter-active {
  transition: all 0.4s ease-in-out;
  border-radius: 22px;
  animation: page-in 1.25s linear;
  position: absolute;
  left: 0;
  top: 0;
}
.music-enter-active {
  animation: musicChange 0.6s;
}
.music-leave-active {
  animation: musicChange 0.3s reverse;
}
@keyframes page-in {
  0% {
    transform: scale(0.92) rotateY(180deg);
    opacity: 0;
  }

  60% {
    transform: scale(0.92) rotateY(90deg);
    opacity: 0;
    z-index: 999;
  }
  80% {
    transform: scale(0.92) rotateY(0);
    opacity: 1;
    z-index: 999;
  }
  100% {
    transform: scale(1) rotateY(0);
    opacity: 1;
    z-index: 999;
  }
}
@keyframes page-out {
  0% {
    transform: scale(1) rotateY(0);
    opacity: 1;
  }

  40% {
    transform: scale(0.92) rotateY(0);
    opacity: 1;
  }
  80% {
    transform: scale(0.92) rotateY(180deg);
    opacity: 0;
  }
  100% {
    transform: scale(0.92) rotateY(180deg);
    opacity: 0;
  }
}

@keyframes musicChange {
  0% {
    opacity: 0;
    transform: translateY(100%);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}
</style>
